/**
 * Created on Jan 2, 2006
 *
 * Copyright (c) 2005 Ganges Organisation all rights reserved.
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation. See the GNU General Public License for more details.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
package org.ganges.expressionengine.grammar;

/**
 * This class represents the expression token generated by the parser while 
 * parsing the string expression. It contains the token string and index in the 
 * expression string.
 * 
 * Example:
 * 1+2+pow(3,4)
 * 1, +, 2, +, pow, (, 3, ',', 4, ) are tokens
 * 
 * @author Parmod Kamboj
 * @author Mohit Gupta
 * 
 * @version 1.0
 */
public class ExpressionToken {

	/**
	 * Value of this token
	 */
	private String value;

	/**
	 * Index of this token in expression string
	 */
	private int	index;

	/**
	 * Constructs the ExpressionToken
	 * 
	 * @param value
	 * @param index
	 */
	public ExpressionToken( String value, int index ) {
		this.value = value;
		this.index = index;
	}

	/**
	 * Gets the value of index.
	 * 
	 * @return Returns the index.
	 */
	public int getIndex() {
		return index;
	}

	/**
	 * Gets the value of value.
	 * 
	 * @return Returns the value.
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "{" + value + ", " + index + "}";
	}
}